[bash] checking wget's return value [if]

Posted by wwrob on Stack Overflow See other posts from Stack Overflow or by wwrob
Published on 2010-04-26T22:16:16Z Indexed on 2010/04/26 22:33 UTC
Read the original article Hit count: 201

Filed under:
|

I'm writing a script to download a bunch of files, and I want it to inform when a particular file doesn't exist.

r=`wget -q www.someurl.com`
if [ $r -ne 0 ]
  then echo "Not there"
  else echo "OK"
fi

But it gives the following error on execution:

./file: line 2: [: -ne: unary operator expected

What's wrong?

© Stack Overflow or respective owner

Related posts about bash

Related posts about wget